package com.celesea.auth.user.entity;

import com.celesea.auth.user.vo.UserVo;
import com.celesea.framework.entity.BaseEntity;
import com.celesea.framework.util.EnvUtil;
import com.celesea.framework.vo.DictionaryVo;

import javax.persistence.Column;
import javax.persistence.Table;

@Table(name = "user_perm_mapping")
public class UserPerm extends BaseEntity {
    // 用户
    public static final Integer PERM_TYPE_USER = 1;
    // 部门
    public static final Integer PERM_TYPE_DEPT = 2;

    @Column(name = "`user_id`", columnDefinition = "用户Id", nullable = false)
    private String userId;
    @Column(name = "`user_name`", columnDefinition = "用户名称")
    private String userName;
    @Column(name = "`perm_type`", columnDefinition = "授权类型", nullable = false)
    private Integer permType;
    @Column(name = "`perm_id`", columnDefinition = "授权Id", nullable = false)
    private String permId;
    @Column(name = "`perm_name`", columnDefinition = "授权名称")
    private String permName;

    public UserPerm() {
    }

    public UserPerm(UserVo user, Integer permType, DictionaryVo item) {
        super.tenantId = EnvUtil.getTenantId();
        this.userId = user.getId();
        this.userName = user.getName();
        this.permType = permType;
        this.permId = item.getId();
        this.permName = item.getName();
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getPermType() {
        return permType;
    }

    public void setPermType(Integer permType) {
        this.permType = permType;
    }

    public String getPermId() {
        return permId;
    }

    public void setPermId(String permId) {
        this.permId = permId;
    }

    public String getPermName() {
        return permName;
    }

    public void setPermName(String permName) {
        this.permName = permName;
    }
}
